package com.test.kupi.page.object;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;

public class PageMain extends Page{
	
	@FindBy(linkText = "USD")
	private WebElement curUSD;
	
	@FindBy(linkText = "BYR")
	private WebElement curBYR;
	
	@FindBy(linkText = "RUB")
	private WebElement curRUB;
	
	public PageMain(WebDriver driver) {
        PageFactory.initElements(driver, this);
        this.driver = driver;
    }
	
	public PageMain chooseCur(String text) {
		if (text.contains("USD")) {
			curUSD.click();
		}
		if (text.contains("BYR")) {
			curBYR.click();
		}
		if (text.contains("RUB")) {
			curRUB.click();
		}
		return this;
	}
	
	public PageMain defaultCur() {
		String s = driver.findElement(By.xpath("//div[@class = 'currency_select']/a[@class = 'item active']")).getText().toString();
		Assert.assertTrue(s.contains("BYR"), "Default Currency is NOT BYR!!!");
		return this;
	}
}
